# coding=utf-8
from lib.Character.BaseAttribute import BaseAttribute


class Growth(object):
    def __init__(self, occuption_type, base, up_base):
        super(Growth, self).__init__()
        self.occuption_type = occuption_type
        self.base_attribute = BaseAttribute(base)
        self.uplevel_attribute = up_base

    def get_attributes(self, level):
        return {
            'stamina':
                self.get_attribute(self.base_attribute.stamina, self.uplevel_attribute['stamina'], level),
            'strengt':
                self.get_attribute(self.base_attribute.strengt, self.uplevel_attribute['strengt'], level),
            'agility':
                self.get_attribute(self.base_attribute.agility, self.uplevel_attribute['agility'], level),
            'intellect':
                self.get_attribute(self.base_attribute.intellect, self.uplevel_attribute['intellect'], level),
            'dodge':
                self.get_attribute(self.base_attribute.dodge, self.uplevel_attribute['dodge'], level),
            'combo':
                self.get_attribute(self.base_attribute.combo, self.uplevel_attribute['combo'], level),
            'critical':
                self.get_attribute(self.base_attribute.critical, self.uplevel_attribute['critical'], level),
            'counter':
                self.get_attribute(self.base_attribute.counter, self.uplevel_attribute['counter'], level)
        }

    def get_attribute(self, base, uplevel, level):
        return int(base + uplevel * level)


class Profession(object):

    def __init__(self, professio_type, base, up_base):
        super(Profession, self).__init__()
        self.professio_type = professio_type
        self.growth = Growth(self.professio_type, base, up_base)

    def get_attributes_equipment(self, level, equipments):
        attributes = self.growth.get_attributes(level)
        return {
            'stamina':
                attributes['stamina'] + equipments.stamina(),
            'strengt':
                attributes['strengt'] + equipments.strengt(),
            'agility':
                attributes['agility'] + equipments.agility(),
            'intellect':
                attributes['intellect'] + equipments.intellect(),
            'dodge':
                attributes['dodge'] + equipments.dodge(),
            'combo':
                attributes['combo'] + equipments.combo(),
            'critical':
                attributes['critical'] + equipments.critical(),
            'counter':
                attributes['counter'] + equipments.counter()
        }
